import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/application/smart_warehouse/warehouse_device_tree_entity.dart';

WarehouseDeviceTreeEntity $WarehouseDeviceTreeEntityFromJson(Map<String, dynamic> json) {
  final WarehouseDeviceTreeEntity warehouseDeviceTreeEntity = WarehouseDeviceTreeEntity();
  final List<WarehouseDeviceTreeEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<WarehouseDeviceTreeEntity>(e) as WarehouseDeviceTreeEntity).toList();
  if (children != null) {
    warehouseDeviceTreeEntity.children = children;
  }
  final String? dictionaryId = jsonConvert.convert<String>(json['dictionaryId']);
  if (dictionaryId != null) {
    warehouseDeviceTreeEntity.dictionaryId = dictionaryId;
  }
  final String? dictionaryType = jsonConvert.convert<String>(json['dictionaryType']);
  if (dictionaryType != null) {
    warehouseDeviceTreeEntity.dictionaryType = dictionaryType;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    warehouseDeviceTreeEntity.id = id;
  }
  final int? level = jsonConvert.convert<int>(json['level']);
  if (level != null) {
    warehouseDeviceTreeEntity.level = level;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    warehouseDeviceTreeEntity.name = name;
  }
  final String? pid = jsonConvert.convert<String>(json['pid']);
  if (pid != null) {
    warehouseDeviceTreeEntity.pid = pid;
  }
  return warehouseDeviceTreeEntity;
}

Map<String, dynamic> $WarehouseDeviceTreeEntityToJson(WarehouseDeviceTreeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  data['dictionaryId'] = entity.dictionaryId;
  data['dictionaryType'] = entity.dictionaryType;
  data['id'] = entity.id;
  data['level'] = entity.level;
  data['name'] = entity.name;
  data['pid'] = entity.pid;
  return data;
}

extension WarehouseDeviceTreeEntityExtension on WarehouseDeviceTreeEntity {
  WarehouseDeviceTreeEntity copyWith({
    List<WarehouseDeviceTreeEntity>? children,
    String? dictionaryId,
    String? dictionaryType,
    String? id,
    int? level,
    String? name,
    String? pid,
  }) {
    return WarehouseDeviceTreeEntity()
      ..children = children ?? this.children
      ..dictionaryId = dictionaryId ?? this.dictionaryId
      ..dictionaryType = dictionaryType ?? this.dictionaryType
      ..id = id ?? this.id
      ..level = level ?? this.level
      ..name = name ?? this.name
      ..pid = pid ?? this.pid;
  }
}
